﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using ART.Common;

namespace ART.Admini.Setting
{
    public partial class OperationLog : System.Web.UI.Page
    {
        private BLL.B_operationLog bll = new BLL.B_operationLog();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();
            }
        }
        protected void BindList()
        {

            #region __________Where语句__________

            string SqlWhere = "  1=1";


            #endregion

            rptOperationLog.PageLink = "OperationLog.aspx";
            rptOperationLog.PageSize = 20;
            rptOperationLog.CurrentPage = LYRequest.GetInt("page", 1);
            string tab = "(SELECT TBAdmin.UserName, operationLog.* FROM  TBAdmin INNER JOIN  operationLog ON TBAdmin.ID = operationLog.AId) as VoperationLog";

            DataSet ds = BLL.GetListByPage.GetDataSet_NoCache(tab, "*", SqlWhere, "", "id desc", "ID", rptOperationLog.CurrentPage, rptOperationLog.PageSize, 1);

            rptOperationLog.RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            JBind.BindList(rptOperationLog, ds.Tables[1]);
        }
        protected void rptOperationLog_ItemCommand(object source, RepeaterCommandEventArgs p1)
        {
            //#warning IsPermissions
            if (!BLL.B_TBAdmin.IsPermissions(15))
            {
                MessageBox.Alert(source, "没有删除权限!");
            }
            else
            {
                int num = int.Parse(p1.CommandArgument.ToString());
                if (p1.CommandName == "lbtnDelete")
                {
                    if (bll.Delete(num))
                    {
                        MessageBox.Alert(source, "删除成功!");
                    }
                    base.Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery);
                }
            }
        }
        protected void lbtnDeletes_Click(object sender, EventArgs p1)
        {
            //#warning IsPermissions
            if (!BLL.B_TBAdmin.IsPermissions(15))
            {
                MessageBox.Alert(sender, "没有删除权限!");
            }
            else
            {
                foreach (RepeaterItem item in this.rptOperationLog.Items)
                {
                    HtmlInputCheckBox box = (HtmlInputCheckBox)item.FindControl("cheId");
                    if (box.Checked)
                    {
                        bll.Delete(int.Parse(box.Value));
                    }
                }
                base.Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery);
            }
        }
    }
}
